<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>ShopCar类实例</title>
      </head>
      <body>     
          <h3>Show All Goods For Sale.</h3>
      
    <div>
      <table border="1" width="450" rules="none" cellspacing="0" cellpadding="0" style="float:left">
      <tr height="50"><td colspan="4" align="center">提供商品如下</td></tr>
      <tr align="center" height="30" bgcolor="lightgrey">
      <td>图片</td>
      <td>名称</td>
      <td>价格(元/斤)</td>
      <td>购买</td>
      </tr>
     
      <c:set var="goodslist" value="#{sessionScope.goodslist}"/>
      <c:choose>
          <c:when test="#{goodslist == null || goodslist.size() == 0}">
              <tr height="100"><td colspan="4" align="center">没有商品可显示！</td></tr>
          </c:when>
              <c:otherwise>
                  <c:forEach var="i" begin="0" end="#{goodslist.size() - 1}">
                  <c:set var="single" value="#{goodslist.get(i)}"/>
                <tr height="50" align="center">
                      <td><img style='width:50px;' src='#{single.imgurl}' /></td>
                      <td>
                          #{single.name}
                      </td>
                      <td>
                          #{single.price}
                      </td>
                      <td>
                          <a href="Docar?action=add&amp;id=#{i}">加入购物车</a>
                      </td>
                      </tr>
                  </c:forEach>
                  
              </c:otherwise>
      </c:choose>


    
    <tr height="50">
    <td align="center" colspan="4"><a href="Shopcar.xhtml">查看购物车</a></td>
    </tr>
    </table>
        <ui:include src="./SmallShopcar.xhtml"></ui:include>

        </div>
    </body>
</html>